package monsmon.term;

import java.awt.Color;

/*
 * Interface for the Terminal-the ui window system
 *
 * Coordinate system:
 * 	The top left corner of the terminal is (0, 0).  The coords will 
 * 	 increace in the positive direction until (get_x_len(), get_y_len())
 * 	 Thus:
 * 		(0, 0)                              (get_x_len(), 0)
 * 		      *----------------------------*
 * 		      |                            |
 * 		      |                            |
 * 		      |     *(3, 3)                |
 * 		      |                            |
 * 		      *----------------------------*
 * 		(0, get_y_len())                (get_x_len(), get_y_len())
 *
 * The operation of a Terminal implementation:
 *	initalization and destruction:
 * 		No important resources are initalized in the constructor
 *		Inititalization should happen in the init function
 *		Initalization must finish before init returns
 *		destroy shall release all resources held by the implementation
 *	drawing:
 *		There shall be two buffers holding the character information
 *			-the draw buffer is not being drawn to the screen
 *			  and is where 
 *			-the screen buffer is rendered to the screen
 *		The draw commands shall specify an x, y location on the 
 *		 screen in character cells.
 *		The the screen will not be updated with draw commands 
 *		 until the update function is called.
 *		After update is called, the draw buffer's contents are in an
 *		 undefined state.
 *		The clear command will set all characters in the draw buffer
 *		 to a ' ' or a non-rendered state and set foreground colors
 *		 to white and background colors to black.
 *		copy_buffer will copy the contents of the screen buffer to 
 *		 the draw buffer.
 *		buff_cp will copy the contents of the draw buffer to a Tchar
 *		 array and return it.
 *		buff_load will copy the contents of the supplied Tchar array
 *		 to the draw buffer
 *		Extension not supported by the implementation 
 *		 (Colors, blinking) will be silently ignored
 *	Events:
 *		The implementation shall maintan a queue of Key events.
 *		When the implementaion detects a event, it will add to the
 *		 event queue.
 *		The implementation will follow standard Key contract and
 *		 use Key constants
 *		poll_event will remove the top of the event queue and remove
 *		 it.  It will return null if no events are present
 *		peek_event will return the top of the queue without removing
 *		 it.  It will return null if no events are present.
 *		clear_event will remove all contents of the queue.
 *
 */
public interface Terminal{

	/*
	 * Initalizes any resources needed
	 */
	public void init();

	/*
	 * Draw routines:
	 *	The specified char is drawn at x,y.
	 *
	 * 	x - x coord
	 * 	y - y coord
	 * 	c - the char to draw
	 * 	fg - foreground color to use
	 * 	bg - background color
	 *
	 */
	public void draw(int x, int y, char c);
	public void draw(int x, int y, char c, Color fg);
	public void draw(int x, int y, char c, Color fg, Color bg);
	public void draw(int x, int y, char c, Color fg, Color bg, 
			boolean blink);
	public void draw(int x, int y, char c, Color fg, boolean blink,
			char altc);
	public void draw(int x, int y, Tchar tc);
	public void draw(int x, int y, char c, Color fg, Color b,
			boolean blink, char altc, Color altfg);
	

	public Surface get_curr_surface();
	/*
	 * Anything written since the last update() call
	 * 	is sent to the screen
	 *
	 * The draw buffer's contents are sent to the show buffer's
	 * The contents of the draw buffer are undefined after this
	 */
	public void update();

	/*
	 * Clears the draw buffer.  chars are replaced with ' ' and 
	 * To clear the actual screen, an update call must then be used
	 */
	public void clear();

	/*
	 * Releases any resources used.  Once called, 
	 * 	do not call any further term methods
	 */
	public void destroy();

	/*
	 * Returns x length of the screen, in chars
	 */
	public int get_x_len();

	/*
	 * Returns y length of the screen, in chars
	 */
	public int get_y_len();


	/*
	 * Copy show buffer to draw buffer
	 * 	show buffer remains the same
	 *
	 */
	public void copy_buff();

	/*
	 * Return the last event from the event queue
	 *
	 */
	public Key poll_event();
	
	public Key peek_event();

	public void clear_event();
}
